package com.dmall.chapter03.section04;

import java.util.Arrays;

/**
 * 暴力解法
 * 时间复杂度：O(n^2)
 * 空间复杂度：O(1)
 * @author xiao1.wang
 * @date 2020-12-01 22:38:34
 */
public class Leetcode1V1 {

    public int[] twoSum(int[] nums, int target) {
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[] {i, j};
                }
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] nums = {2, 7, 11, 15};
        Leetcode1V1 leetcode1 = new Leetcode1V1();
        int[] res = leetcode1.twoSum(nums, 26);
        System.out.println(Arrays.toString(res));
    }
}
